package logic

import (
	"context"
	"encoding/json"
	"github.com/hibiken/asynq"
	"github.com/zeromicro/go-zero/core/logx"
	"mrshen_asynq_delay/internal/svc"
)

type CloseHomestayOrderHandler struct {
	svcCtx *svc.ServiceContext
}

func NewCloseHomestayOrderHandler(svcCtx *svc.ServiceContext) *CloseHomestayOrderHandler {
	return &CloseHomestayOrderHandler{
		svcCtx: svcCtx,
	}
}

func (l *CloseHomestayOrderHandler) ProcessTask(ctx context.Context, t *asynq.Task) error {
	var p string
	if err := json.Unmarshal(t.Payload(), &p); err != nil {
		logx.Error("延迟任务打印错误日志: ", p)
	}
	logx.Info("延迟任务打印消息: ", p)

	return nil
}
